<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>
NavigatorService class
</TITLE>

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../resources/stylesheet.css" TITLE="Style">
</HEAD>

<BODY BGCOLOR="white">


<!-- ========= START OF TOP NAVBAR ======= -->

<table border="0" width="100%">
<tr>
<td width="50%">
<p align="left">
<a href="http://mvvmbasics.mobilemotion.eu/" target="_blank" title="MVVMbasics Homepage"><img src="../../resources/logo_mvvmbasics.png" alt="MVVMbasics Logo" border="0"></a>
</p>
</td>
<td width="50%">
<p align="right">
<a href="http://www.mobilemotion.eu/" target="_blank" title="mobilemotion.eu Homepage"><img src="../../resources/logo_mobilemotion.png" alt="mobilemotion.eu Logo" border="0"></a>
</p>
</td>
</tr>
</table>

<HR>

<p><a href="../../index.htm" title="MVVMbasics Class Reference Homepage">Back to Class Reference home page</a></p>

<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">MVVMbasics.Services</FONT>
<BR>
Class NavigatorService
</H2>

<CODE>
<a href="INavigatorService.htm" title="INavigatorService">MVVMbasics.Services.INavigatorService</a>
<br>
&nbsp;&nbsp;<IMG SRC="../../resources/inherit.gif" ALT="implemented by "><B>MVVMbasics.Services.NavigatorService</B>
<br>&nbsp;
</CODE>
<HR>
<CODE>
&nbsp;<br>
[<a href="../Attributes/MvvmService.htm" title="MvvmService">MvvmService</a>]<br>
public class <B>NavigatorService</B> : <a href="INavigatorService.htm" title="INavigatorService">INavigatorService</a>
</CODE>

<P>
Service which provides page / window navigation functionality. Includes both "standard" navigation methods which navigate backwards as well as a View-/Viewmodel-Locator that stores mappings of View to Viewmodel and allows to directly navigate to a View that is associated with a given Viewmodel.
</P>

<hr>

<!-- ======== METHOD SUMMARY ======== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#Register(object)">Register&lt;T&gt;</a></B>(object view) where T : <a href="../Viewmodels/BaseViewmodel.htm" title="BaseViewmodel">BaseViewmodel</a></CODE>
<BR>
<span class="Indented">Registers a mapping of Viewmodel to View.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#RegisterAll(Assembly)">RegisterAll</a></B>(<a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly%28v=vs.110%29.aspx" target="_blank" title="System.Reflection.Assembly">Assembly</a> assembly = null)</CODE>
<BR>
<span class="Indented">Traverses all Views and registers all that provide a <a href="../Attributes/MvvmNavigationTarget.htm" title="MvvmNavigationTarget">MvvmNavigationTarget</a> attribute.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#RegisterAll(string,Assembly)">RegisterAll</a></B>(string ns, <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly%28v=vs.110%29.aspx" target="_blank" title="System.Reflection.Assembly">Assembly</a> assembly = null)</CODE>
<BR>
<span class="Indented">Traverses all Views that are located within a given namespace and registers all that provide a <a href="../Attributes/MvvmNavigationTarget.htm" title="MvvmNavigationTarget">MvvmNavigationTarget</a> attribute.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>object&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#Retrieve()">Retrieve&lt;T&gt;</a></B>() where T : <a href="../Viewmodels/BaseViewmodel.htm" title="BaseViewmodel">BaseViewmodel</a></CODE>
<BR>
<span class="Indented">Returns a View or throws an exception if no matching View has been registered.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#NavigateTo(params)">NavigateTo&lt;T&gt;</a></B>(params <a href="Parameter.htm" title="Parameter">Parameter</a>[] parameters) where T : <a href="../Viewmodels/BaseViewmodel.htm" title="BaseViewmodel">BaseViewmodel</a></CODE>
<BR>
<span class="Indented">Retrieves a View and navigates to the corresponding page / window.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#NavigateTo(string,object)">NavigateTo&lt;T&gt;</a></B>(string key, object value) where T : <a href="../Viewmodels/BaseViewmodel.htm" title="BaseViewmodel">BaseViewmodel</a></CODE>
<BR>
<span class="Indented">Retrieves a View and navigates to the corresponding page / window, passing one parameter.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#NavigateTo(ParameterList)">NavigateTo&lt;T&gt;</a></B>(<a href="ParameterList.htm" title="ParameterList">ParameterList</a> parameters) where T : <a href="../Viewmodels/BaseViewmodel.htm" title="BaseViewmodel">BaseViewmodel</a></CODE>
<BR>
<span class="Indented">Retrieves a View and navigates to the corresponding page / window.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#NavigateBack()">NavigateBack</a></B>()</CODE>
<BR>
<span class="Indented">Navigates to the last View on the back stack.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#SetBackParameters(params)">SetBackParameters</a></B>(params <a href="Parameter.htm" title="Parameter">Parameter</a>[] parameters)</CODE>
<BR>
<span class="Indented">Stores parameters to be passed to the previous View on the next backward navigation event.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#SetBackParameters(string,object)">SetBackParameters</a></B>(string key, object value)</CODE>
<BR>
<span class="Indented">Stores one parameter to be passed to the previous View on the next backward navigation event.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#SetBackParameters(ParameterList)">SetBackParameters</a></B>(<a href="ParameterList.htm" title="ParameterList">ParameterList</a> parameters)</CODE>
<BR>
<span class="Indented">Stores parameters to be passed to the previous View on the next backward navigation event.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#ClearBackParameters()">ClearBackParameters</a></B>()</CODE>
<BR>
<span class="Indented">Removes parameters which have been stored to be passed to the previous View on the next backward navigation event.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>bool&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#CanGoBack()">CanGoBack</a></B>()</CODE>
<BR>
<span class="Indented">Checks whether a backwards navigation is possible or not (the latter ist the case if the current View is the Application's main View).</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#RemoveBackEntry()">RemoveBackEntry</a></B>()</CODE>
<BR>
<span class="Indented">Removes the previously shown View from the back stack.</span>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>void&nbsp;</CODE></FONT></TD>
<TD>
<CODE><B><a href="#ClearBackStack()">ClearBackStack</a></B>()</CODE>
<BR>
<span class="Indented">Removes all entries from the back stack.</span>
</TD>
</TR>

</TABLE>
&nbsp;

<!-- ========= METHOD DETAIL ======== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="Register(object)"><!-- --></A><H3>
Register&lt;T&gt;</H3>
<CODE>public void <B>Register&lt;T&gt;</B>(object view) where T : <a href="../Viewmodels/BaseViewmodel.htm" title="BaseViewmodel">BaseViewmodel</a></CODE>
<p class="Indented">Registers a mapping of Viewmodel to View. Viewmodel must be supplied as <a href="http://msdn.microsoft.com/en-us/library/system.type%28v=vs.110%29.aspx" target="_blank" title="System.Type">Type</a> object, View must be supplied as <a href="http://msdn.microsoft.com/en-us/library/system.uri%28v=vs.110%29.aspx" target="_blank" title="System.Uri">Uri</a> object. The Viewmodel type must be a subtype of <a href="../Viewmodels/BaseViewmodel.htm" title="BaseViewmodel">BaseViewmodel</a>. Exceptions will be thrown if this type constraints is not fulfilled, or if a mapping with the specified Viewmodel type exists already.</p>

<HR>

<A NAME="RegisterAll(Assembly)"><!-- --></A><H3>
RegisterAll</H3>
<CODE>public void <B>RegisterAll</B>(<a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly%28v=vs.110%29.aspx" target="_blank" title="System.Reflection.Assembly">Assembly</a> assembly = null)</CODE>
<p class="Indented">Traverses all Views and registers all that provide a <a href="../Attributes/MvvmNavigationTarget.htm" title="MvvmNavigationTarget">MvvmNavigationTarget</a> attribute. An exception is thrown if one of the traversed Views references a Viewmodel type that has been registered already.</p>

<div class="Indented">
<B>Parameters:</B>
<p class="Indented">
<CODE>assembly</CODE> - Assembly to be scanned. If NULL, the calling assembly will be scanned.<br>
</p>
</div>

<HR>

<A NAME="RegisterAll(string,Assembly)"><!-- --></A><H3>
RegisterAll</H3>
<CODE>public void <B>RegisterAll</B>(string ns, <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly%28v=vs.110%29.aspx" target="_blank" title="System.Reflection.Assembly">Assembly</a> assembly = null)</CODE>
<p class="Indented">Traverses all Views that are located within a given namespace inside a given assembly and registers all that provide a <a href="../Attributes/MvvmNavigationTarget.htm" title="MvvmNavigationTarget">MvvmNavigationTarget</a> attribute. An exception is thrown if one of the traversed Views references a Viewmodel type that has been registered already.</p>

<div class="Indented">
<B>Parameters:</B>
<p class="Indented">
<CODE>ns</CODE> - Namespace to be scanned. If ends with '.*', also sub-directories will be scanned. If NULL, the whole assembly will be scanned.<br>
<CODE>assembly</CODE> - Assembly to be scanned. If NULL, the calling assembly will be scanned.<br>
</p>
</div>

<HR>

<A NAME="Retrieve()"><!-- --></A><H3>
Retrieve&lt;T&gt;</H3>
<CODE>public object <B>Retrieve&lt;T&gt;</B>() where T : <a href="../Viewmodels/BaseViewmodel.htm" title="BaseViewmodel">BaseViewmodel</a></CODE>
<p class="Indented">Returns a View or throws an exception if no matching View has been registered.</p>

<HR>

<A NAME="NavigateTo(params)"><!-- --></A><H3>
NavigateTo</H3>
<CODE>public void <B>NavigateTo&lt;T&gt;</B>(params <a href="Parameter.htm" title="Parameter">Parameter</a>[] parameters) where T : <a href="../Viewmodels/BaseViewmodel.htm" title="BaseViewmodel">BaseViewmodel</a></CODE>
<p class="Indented">Retrieves a View and navigates to the corresponding page / window.</p>

<HR>

<A NAME="NavigateTo(string,object)"><!-- --></A><H3>
NavigateTo</H3>
<CODE>public void <B>NavigateTo&lt;T&gt;</B>(string key, object value) where T : <a href="../Viewmodels/BaseViewmodel.htm" title="BaseViewmodel">BaseViewmodel</a></CODE>
<p class="Indented">Retrieves a View and navigates to the corresponding page / window, passing one parameter.</p>

<HR>

<A NAME="NavigateTo(ParameterList)"><!-- --></A><H3>
NavigateTo</H3>
<CODE>public void <B>NavigateTo&lt;T&gt;</B>(<a href="ParameterList.htm" title="ParameterList">ParameterList</a> parameters) where T : <a href="../Viewmodels/BaseViewmodel.htm" title="BaseViewmodel">BaseViewmodel</a></CODE>
<p class="Indented">Retrieves a View and navigates to the corresponding page / window.</p>

<HR>

<A NAME="NavigateBack()"><!-- --></A><H3>
NavigateBack</H3>
<CODE>public void <B>NavigateBack</B>()</CODE>
<p class="Indented">Navigates to the last View on the back stack.</p>

<HR>

<A NAME="SetBackParameters(params)"><!-- --></A><H3>
SetBackParameters</H3>
<CODE>public void <B>SetBackParameters</B>(params <a href="Parameter.htm" title="Parameter">Parameter</a>[] parameters)</CODE>
<p class="Indented">Stores parameters to be passed to the previous View on the next backward navigation event.</p>

<div class="Indented">
<B>Parameters:</B>
<p class="Indented">
<CODE>parameters</CODE> - Parameters to be stored for passing to the previos View.<br>
</p>
</div>

<HR>

<A NAME="SetBackParameters(string,object)"><!-- --></A><H3>
SetBackParameters</H3>
<CODE>public void <B>SetBackParameters</B>(string key, object value)</CODE>
<p class="Indented">Stores one parameter to be passed to the previous View on the next backward navigation event.</p>

<div class="Indented">
<B>Parameters:</B>
<p class="Indented">
<CODE>key</CODE> - Key of the parameter to be stored for passing to the previos View.<br>
<CODE>value</CODE> - Value of the parameter to be stored for passing to the previos View.<br>
</p>
</div>

<HR>

<A NAME="SetBackParameters(ParameterList)"><!-- --></A><H3>
SetBackParameters</H3>
<CODE>public void <B>SetBackParameters</B>(<a href="ParameterList.htm" title="ParameterList">ParameterList</a> parameters)</CODE>
<p class="Indented">Stores parameters to be passed to the previous View on the next backward navigation event.</p>

<div class="Indented">
<B>Parameters:</B>
<p class="Indented">
<CODE>parameters</CODE> - Parameters to be stored for passing to the previos View.<br>
</p>
</div>

<HR>

<A NAME="ClearBackParameters()"><!-- --></A><H3>
ClearBackParameters</H3>
<CODE>public void <B>ClearBackParameters</B>()</CODE>
<p class="Indented">Removes parameters which have been stored to be passed to the previous View on the next backward navigation event.</p>

<HR>

<A NAME="ClearBackParameters()"><!-- --></A><H3>
ClearBackParameters</H3>
<CODE>public void <B>ClearBackParameters</B>()</CODE>
<p class="Indented">Removes parameters which have been stored to be passed to the previous View on the next backward navigation event.</p>

<HR>

<A NAME="CanGoBack()"><!-- --></A><H3>
CanGoBack</H3>
<CODE>public bool <B>CanGoBack</B>()</CODE>
<p class="Indented">Checks whether a backwards navigation is possible or not (the latter ist the case if the current View is the Application's main View).</p>

<div class="Indented">
<B>Returns:</B>
<p class="Indented">
TRUE if a backwards navigation is possible, FALSE otherwise.<br>
</p>
</div>

<HR>

<A NAME="RemoveBackEntry()"><!-- --></A><H3>
RemoveBackEntry</H3>
<CODE>public void <B>RemoveBackEntry</B>()</CODE>
<p class="Indented">Removes the previously shown View from the back stack.</p>

<HR>

<A NAME="ClearBackStack()"><!-- --></A><H3>
ClearBackStack</H3>
<CODE>public void <B>ClearBackStack</B>()</CODE>
<p class="Indented">Removes all entries from the back stack.</p>

<!-- ========= END OF CLASS DATA ========= -->
<HR>

</body>
</HTML>